// 节流
function debounded(func, await) {
  let timeout;
  return function () {
    let ctx = this
    let arg = arguments
    if (timeout) {
      clearTimeout(timeout);
    }
    timeout = setTimeout(() => {
      func.apply(ctx, arg)
    }, await)
  }
}

// 防抖
function throtteScroll(func, await) {
  let preTime = Date.now()
  return function () {
    let curTime = Date.now()
    if (curTime - preTime > await) {
      func.apply(this, arguments)
    }
    preTime = curTime
  }
}